#include<iostream>
#include<string>
using namespace std;
string s, t;
int n;
int main()
{
	cin >> n;
	cin >> s >> t;
	bool flag = 0;
	int j = 0;
	for (int i = 0; i < s.size(); i++, j++) {
		if (s[i] == t[j])continue;
		else if (s[i] == '0' && t[j] == 'o')continue;
		else if (s[i] == 'o' && t[j] == '0')continue;
		else if (s[i] == '1' && t[j] == 'l')continue;
		else if (s[i] == 'l' && t[j] == '1')continue;
		else flag = 1;
	}
	if (flag)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}